(()=>{"use strict";const e="Tag Manager: ",t=function(){let e=!1;try{const t=window;e=t&&t.debug||t.location&&(t.location.search||"").toLowerCase().indexOf("debug=")>-1}catch(e){}return e}();function n(n){t&&console&&console.error(`${e} ${n}`)}function o(e){let t=e;try{t=JSON.parse(e)}catch(e){n("Parse error in string"),n(e.message)}return t}function r(e){return o(JSON.stringify(e))}const i="_api/tag-manager/api/v1/tags/",c=`${i}sites/`,a=[".wix.com",".editorx.com"],s="22bef345-3c5b-4c18-b782-74d4085112ff",d=!!document.documentMode;function u(e,t,n){let o;d?(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!0,!0,n)):o=new CustomEvent(e,{detail:n}),t&&t.dispatchEvent&&setTimeout((()=>{t.dispatchEvent(o)}),0)}const l="TagManagerLoaded",f="LoadingTags",g="TagLoaded",p="TagLoadError",m="TagManagerConfigSet";let h=[];const b=[],y=[],w=[];let E,T=[],v={},I=!1;function A(){return w}function C(){return r(v)}function x(e){return Object.keys(e).filter((t=>!!e[t]&&-1===T.indexOf(t)))}function N(e){h=e}function P(){return r(h)}function S(e){b.push(e)}function O(){return r(b)}function L(e){y.push(e)}function M(){return r(y)}function $(){E||I||(I=!0)}function j(e){E||"function"!=typeof e||(E=e),I=!1}function k(){return E}function R(){if(I)return I=!1,s;const e=document.currentScript;let t=!1;let n;if(e instanceof HTMLScriptElement&&w.forEach((o=>{!t&&o.tag.appInfo&&o.embeddedNodes.forEach((r=>{var i;t||r===e&&(n=(null==(i=o.tag)||null==(i=i.appInfo)?void 0:i.id)||"",t=!0)}))})),!n){const t=function(e){let t="Script not identified";if(e instanceof HTMLScriptElement){const{type:n,src:o}=e;t=`type: ${n||"No Type Found"} src: ${o||"No URL Found"}`}return t}(e),o=`App not found for script ${t}, errorId: 404C`;console.error(o),n=new Error(o)}return n}function D(e,t,o){const r=()=>{try{if("function"==typeof e)return e(t)}catch(e){n(e)}};return!0===o?setTimeout(r,0):r()}function H(e,t,n,o){return()=>{o(n),function(e){h=h.filter((t=>t.name!==e))}(n.name),u(e,window,{tagName:t,embed:r(n)})}}const U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function B(e,t){const n=function(){let e="";for(let t=0;t<16;t++)e+=U.charAt(Math.floor(52*Math.random()));return e}(),o=function(e){return`(function(getAccessToken){\n Object.defineProperty(globalThis, "${e}", {\n value: getAccessToken,\n enumerable: false,\n configurable: true,\n writable: true,\n });\n }(wixEmbedsAPI.getAccessTokenFunction()))`}(n),r=function(e,t,n){return`import { injectAccessTokenFunction } from "${e}";\n if(injectAccessTokenFunction){\n injectAccessTokenFunction(${t}, "${n}");\n } else {\n console.error("AppId ${n} does not expose function correctly, error code: Client 404");\n }`}(e,n,t),i=()=>{delete globalThis[id]};return{moduleScriptConfig:{node:{tag:"SCRIPT",attributes:{type:"module"},content:r},callbacks:{onload:function(){i(),this.parentNode.removeChild(this)},onerror:function(){i(),this.parentNode.removeChild(this)}}},helperScriptConfig:{tag:"SCRIPT",content:o}}}function F(e,t,n){let o;return e.nodeType===Node.TEXT_NODE?o=document.createTextNode(e.content):e.nodeType===Node.COMMENT_NODE?o=document.createComment(e.content):(o=document.createElement(e.tag),e&&e.attributes instanceof NamedNodeMap?Array.prototype.forEach.call(e.attributes,(e=>{_(o,e.name,e.value)})):"object"==typeof e.attributes&&Object.keys(e.attributes).forEach((t=>{void 0!==typeof e.attributes[t]&&_(o,t,e.attributes[t])})),"SCRIPT"===e.tag?o=function(e,t,n,o){void 0===t&&(t="");if(o&&"module"===e.getAttribute("type")&&"true"===e.getAttribute("accesstoken")){let r=e.src;!r&&t&&(r=q(t)),e=null;const{helperScriptConfig:i,moduleScriptConfig:c}=B(r,o),a=()=>{const e=F(c.node,c.callbacks,o);document.head.appendChild(e)};return F(i,{onload:a,onerror:null==n?void 0:n.onerror},o)}!function(e,t,n){void 0===t&&(t="");const o=t&&!!t.trim();o&&(e.src=q(t));e.addEventListener("load",(function(){D(n&&n.onload,null)}),!1),e.addEventListener("error",(function(){D(n&&n.onerror,null)}),!1)}(e,t,n);return e}(o,e.content,t,n):e.children&&e.children.length>0&&e.children.forEach((e=>{const r=F(e,t,n);o.appendChild(r)}))),o}function _(e,t,n){e.setAttribute(t,n)}function q(e){const t=new Blob([e],{type:"text/javascript;charset=utf-8"});return URL.createObjectURL(t)}function J(e){const t=[],n=document.createElement("DIV");return n.innerHTML=e,Array.prototype.forEach.call(n.childNodes,(e=>{const n=Y(e);t.push(n)})),t}function Y(e){const t=e.nodeType,n=e.innerHTML||e.textContent||e.nodeValue,o=[];return e.hasChildNodes()&&Array.prototype.forEach.call(e.childNodes,(e=>{o.push(Y(e))})),{nodeType:t,tag:e.nodeName,attributes:e.attributes,content:n,children:o}}let z=function(e){return e.HEAD="head",e.BODY_START="bodyStart",e.BODY_END="bodyEnd",e}({});function V(e,t,n){const o=e.filter((e=>!e.embeddedNodes)),r=function(e,t){return!(!e||"true"!==e[t])}(n,"specs.tagManagerRenderTagByPageID"),i=r?function(e,t){return e.filter((e=>function(e,t){return!(t.id&&(n=e,null!=(o=n.tag)&&null!=(o=o.pages)&&o.length))||((e,t)=>{var n;return(null==(n=e.tag)||null==(n=n.pages)?void 0:n.includes(t.id||""))||!1})(e,t);var n,o}(e,t)))}(o,t):o,c=i.map((e=>e.tag));N(c),u(f,window,c),i.forEach((e=>{var t;const n=null==(t=e.tag.appInfo)?void 0:t.id;e.embeddedNodes=e.embeddedNodes||[];const o=e.tag,r=J(o.content),i=o.position&&o.position.toLowerCase()!==z.HEAD?document.body:document.head;!function(e,t,n,o,r,i){let c=0;const a=()=>{c-=1,c>=0&&D(t.onload,{})},s=()=>{c-=1,c>=0&&D(t.onerror,{error:!0})},d=n.firstChild;e.forEach((e=>{"SCRIPT"===e.tag&&(c+=1);const t=F(e,{onload:a,onerror:s},i);r.push(t),o?n.insertBefore(t,d):n.appendChild(t)})),0===c&&D(t.onload,{},!0)}(r,{onload:H(g,o.name,o,S),onerror:H(p,o.name,o,L)},i,o.position===z.BODY_START,e.embeddedNodes,n)}))}function W(e,t,n,o){const r=o&&o.headers||{},i=o&&o.query||{};r["content-type"]=r["content-type"]||"application/json";const c=new XMLHttpRequest,a=o&&o.postBody?"POST":"GET",s=`${e}${function(e){let t="";"object"==typeof e&&Object.keys(e).forEach((n=>{if(void 0!==e[n]){const o=encodeURIComponent(e[n]);t+=`${encodeURIComponent(n)}=${o}&`}}));return t=t?t.substr(0,t.length-1):"",t?`?${t}`:""}(i)}`;c.open(a,s,!0),c.onreadystatechange=()=>{if(4===c.readyState){const e=c.status;e<200||e>=300?D(n,{status:e,responseText:c.responseText}):D(t,c.responseText)}},Object.keys(r).forEach((e=>{void 0!==r[e]&&c.setRequestHeader(e,r[e])})),c.send(o&&o.postBody||null)}function X(e,t){void 0===t&&(t=location.search);let n=t.split(`${e}=`)[1];return n=n?decodeURIComponent(n.split("&")[0]):void 0,n}function G(e,t){const i=o(e),{currentPageID:c,initConsentPolicyManager:a=!1}=t;if(i.errors&&i.errors.length>0&&n(JSON.stringify(i.errors)),i.config){const e=window.consentPolicyManager;(d=i.config.consentPolicy)&&"object"==typeof d&&(T=[...T,...x(d)]),a&&e&&e.init({consentPolicy:i.config.consentPolicy}),"object"!=typeof(s=i.config)||Array.isArray(s)||(v={...v,...s},u(m,window,r(v)))}var s,d;if(i.tags){i.tags.forEach((e=>{var t;const n=e.loadOnce||(null==(t=e.content)?void 0:t.includes('load-once="true"'));w.push({tag:{...e,loadOnce:n},embeddedNodes:null})}));const e={id:c};V(A(),e,i.config.experiments||{})}}function K(e,t,n){return`${e&&!function(e){let t=!1;return a.forEach((e=>{t||(t=location.hostname.indexOf(e)>0)})),t||e}(!!n)?e:""}/${c}${t}`}async function Q(e){const{metasiteId:t,htmlsiteId:o,baseUrl:r,wixSite:i,language:c,categories:a}=e,d=X("site-override"),u=X("apps-override"),l=K(r,t,i),f=window.consentPolicyManager,g=!i&&f?f._getConsentPolicyHeader():{},p=function(e){const t=e.wixEmbedsAPI,n=t&&t.getCurrentPageInfo;return"function"==typeof n?n():{}}(window),m=X("omit"),h=await async function(){let e;const t=k();if("function"==typeof t)try{e=await t()}catch(e){}e||(e=D(window.wixEmbedsAPI.getAppToken,s));return e}();h&&(g.authorization=h),W(l,(e=>{G(e,{initConsentPolicyManager:!a&&!!i,currentPageID:p.id})}),(e=>{n(`Error loading site tags at ${l}`),n(e.message)}),{query:{wixSite:!!i,htmlsiteId:o,language:c,categories:a,omit:m,siteOverrideId:d,appsOverrideId:u},headers:g})}function Z(e){A().forEach((e=>{e.tag.loadOnce||(e.embeddedNodes&&e.embeddedNodes.forEach((e=>{D((()=>{e.parentNode.removeChild(e)}))})),e.embeddedNodes=null)}));V(A(),e,C().experiments||{})}function ee(e){if(e&&e.detail&&e.detail.policy){const t=x(e.detail.policy);t.length&&Q({baseUrl:window.wixEmbedsAPI.getExternalBaseUrl(),htmlsiteId:window.wixEmbedsAPI.getHtmlSiteId(),metasiteId:window.wixEmbedsAPI.getMetaSiteId(),wixSite:window.wixEmbedsAPI.isWixSite(),language:window.wixEmbedsAPI.getLanguage(),categories:t})}}!function(){const e=window;function t(){const t=e.wixEmbedsAPI;!function(){const t=Object.freeze({getLoadedTags:O,getLoadingTags:P,getLoadErrorTags:M,getConfig:C,getAppId:R});Object.defineProperty(e,"wixTagManager",{value:t,writable:!1,configurable:!1,enumerable:!0}),u(l,window,window.wixTagManager)}(),function(e){if("function"==typeof e.getAccessTokenFunction){$();j(e.getAccessTokenFunction())}}(t),Q({baseUrl:t.getExternalBaseUrl(),htmlsiteId:t.getHtmlSiteId(),metasiteId:t.getMetaSiteId(),language:t.getLanguage(),wixSite:t.isWixSite()}),t.registerToEvent("pageNavigation",Z),document.addEventListener("consentPolicyChanged",ee)}!function(){const n=e.wixEmbedsAPI;n&&"function"==typeof n.registerToEvent?t():e.addEventListener("wixEmbedsAPIReady",t,!1)}()}()})(); //# sourceMappingURL=siteTags.bundle.min.js.map